/**
 * @file system_test.c
 * @author liangwenhao (1943080020@qq.com)
 * @brief 
 * @version 0.1
 * @date 2021-07-27
 * 
 * @copyright Copyright (c) 2021
 * 
 * @authorGitee  https://gitee.com/liangwenhao
 * @authorGithub https://github.com/WHaoL
 * @authorBlogs https://blog.csdn.net/liangwenhao1108
 *  
 * @Code Description: 这次是调用系统的system函数
 *  
 */

#include "apue.h"
#include <sys/wait.h>

int main(void)
{
    int status;

    if ((status = system("date")) < 0)
        err_sys("system() error");

    pr_exit(status);

    if ((status = system("nosuchcommand")) < 0)
        err_sys("system() error");

    pr_exit(status);

    if ((status = system("who; exit 44")) < 0)
        err_sys("system() error");

    pr_exit(status);

    exit(0);
}

/*

lwh@lwh-HP-Notebook:~/ProjsGit/apue/APUE_my/08_Process_Ctl$ ./system_test 
Tue 27 Jul 2021 12:40:39 PM CST
normal termination, exit status = 0

sh: 1: nosuchcommand: not found
normal termination, exit status = 127

lwh      tty7         2021-07-27 09:02 (:0)
normal termination, exit status = 44

*/